package com.sunday.volunteer.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.sunday.volunteer.R;
import com.sunday.volunteer.entity.Member;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by admin on 2017/1/10.
 */

public class GroupAdapter extends RecyclerViewAdapter{

    public GroupAdapter(List list, int layout) {
        super(list, layout);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(View itemView, int viewType) {
        return new ViewHolder(itemView);
    }
    public class ViewHolder extends MyViewHolder{
        @Bind(R.id.group_name)
        TextView group_name;
        @Bind(R.id.logo)
        ImageView logo;
        @Bind(R.id.ratingStar)
        RatingBar ratingStar;
        @Bind(R.id.user_type)
        TextView user_type;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this , itemView);
            itemView.setOnClickListener(onClickListener);
        }

        @Override
        public void bind(MyViewHolder holder, Object object, int position) {
            Member item = (Member)object;
            itemView.setTag(R.id.item ,item);
            if(item == null){
                return;
            }
            setText(group_name , item.getName());
            setText(user_type , item.getUserTypeStr());
            //ratingStar.setRating(4);
            setImage(logo ,item.getLogo() , 80 ,80);
        }
    }
}
